import Vue from "vue";
import VueRouter from "vue-router";
import Login from '../views/login'
import Loyout from '../views/loyout'


// 引入子组件
import Home from '../views/home'
import Member from '../views/member'
import Supplier from '../views/supplier'
import Goods from '../views/goods'
import Order from '../views/order'
import Staff from '../views/staff'

Vue.use(VueRouter);

const routes = [
  /* 登录 */
  {
    path:'/login',
    name:'login',
    component:Login
  },
  /* 后台首页 */
  {
    path:'/',
    name:'loyout',
    component:Loyout,
    /* 重定向 */
    redirect:'/home/',
    /* loyout下的子路由 */
    children:[
      {
        path:'/home/',
        name:'home',
        component:Home,
        meta:{
          title:'首页'
        }
      },
      {
        path:'/member/',
        name:'member',
        component:Member,
        meta:{
          title:'会员管理'
        }
      },
      {
        path:'/supplier/',
        name:'supplier',
        component:Supplier,
        meta:{
          title:'供应商管理'
        }
      },
      {
        path:'/goods/',
        name:'goods',
        component:Goods,
        meta:{
          title:'商品管理'
        }
      },
      {
        path:'/order/',
        name:'order',
        component:Order,
        meta:{
          title:'订单管理'
        }
      },
      {
        path:'/staff/',
        name:'staff',
        component:Staff,
        meta:{
          title:'员工管理'
        }
      },

    ]
  }
];

const router = new VueRouter({
  // mode:'history',
  base:process.env.BASE_URL,
  routes
});

export default router;
